package leetcode.lcp0068;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	int mod = (int) 1e9 + 7;

	public int beautifulBouquet(int[] flowers, int cnt) {
		int[] h = new int[(int) 1e5 + 1];
		int l = 0, r = 0;
		long ans = 0;
		while (r < flowers.length) {
			int f = flowers[r];
			h[f]++;
			while (h[f] > cnt) {
				h[flowers[l]]--;
				l++;
			}
			ans += r - l + 1;
			ans %= mod;
			r++;
		}
		return (int) ans;
	}

	@Override
	public void debug4() {
		H.compare(8, this.beautifulBouquet(H.str2array3("[1,2,3,2]"), 1));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
